/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2016
 */

package com.jzwl.site.manager.nodetype.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


import com.jzwl.system.base.controller.BaseController;
import com.jzwl.common.page.PageObject;
import com.jzwl.site.manager.nodetype.pojo.*;
import com.jzwl.site.manager.nodetype.dao.*;
import com.jzwl.site.manager.nodetype.service.*;

/**
 * SiteNodeType
 * SiteNodeType
 * siteNodeType
 * <p>Title:SiteNodeTypeController </p>
 * 	<p>Description:SiteNodeType </p>
 * 	<p>Company: </p> 
 * 	@author aotu-code 
 */
@Controller
@RequestMapping("/siteNodeType")
public class SiteNodeTypeController  extends BaseController {
	
	@Autowired
	private SiteNodeTypeService siteNodeTypeService;
	
	/**
	 * 跳转到添加SiteNodeType的页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toAddSiteNodeType")
	public ModelAndView toAddsiteNodeType(HttpServletRequest request, HttpServletResponse response) {
		
		ModelAndView mov = new ModelAndView();
		
		createParameterMap(request);
		
		mov.setViewName("/manager/nodetype/add");
		return mov;
	}
	
	/**
	 * 添加SiteNodeType
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/addSiteNodeType")
	public ModelAndView addsiteNodeType(HttpServletRequest request, HttpServletResponse response) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		ModelAndView mov = new ModelAndView();
		
		createParameterMap(request);
		
		try{
			boolean flag = siteNodeTypeService.addSiteNodeType(paramsMap);
			if(!flag){
				mov.addObject("msg", "添加SiteNodeType失败!");
				mov.setViewName("/error");
				
			}else{
				mov.setViewName("redirect:/siteNodeType/siteNodeTypeList.html");
			}
		}catch(Exception e){
			e.printStackTrace();
			mov.addObject("msg", "添加SiteNodeType失败!");
			mov.setViewName("/error");
		}
		
		
		return mov;
	}
	
	/**
	 * siteNodeTypelist
	 */
	@RequestMapping(value = "/siteNodeTypeList")
	public ModelAndView siteNodeTypeList(HttpServletRequest request, HttpServletResponse response) {
	
		ModelAndView mov = new ModelAndView();
		
		createParameterMap(request);
		
		PageObject po = new PageObject();
		
		try{
			paramsMap.put("isDelete", 0);
			po = siteNodeTypeService.querySiteNodeTypeList(paramsMap);
			
			mov.addObject("list", po.getDatasource());
			mov.addObject("totalProperty", po.getTotalCount());
			mov.addObject("page", po);
			mov.setViewName("/manager/nodetype/list");
		}catch(Exception e){
		
			e.printStackTrace();
			mov.addObject("msg", "siteNodeType查询失败");
			mov.setViewName("/error");
		}
		
		return mov;
	}
	
	
	/**
	 * 跳转到修改siteNodeType页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toUpdateSiteNodeType")
	public ModelAndView toUpdateSiteNodeType(HttpServletRequest request, HttpServletResponse response) {
		
		ModelAndView mov = new ModelAndView();
		
		createParameterMap(request);
		
		try{
			
			SiteNodeType siteNodeType=siteNodeTypeService.getById(paramsMap);

			mov.addObject("obj", siteNodeType);
			mov.setViewName("/manager/nodetype/edit");
		}catch(Exception e){
			e.printStackTrace();
			mov.addObject("msg", "siteNodeType查询失败");
			mov.setViewName("/error");
		}
		
		return mov;
	}
	
	/**
	 * 修改siteNodeType
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/updateSiteNodeType")
	public ModelAndView updateSiteNodeType(HttpServletRequest request, HttpServletResponse response) {
		
		ModelAndView mov = new ModelAndView(); 
		
		createParameterMap(request);
		
		try{
		
			boolean flag = siteNodeTypeService.updateSiteNodeType(paramsMap);
			
			if(!flag){
				mov.addObject("msg", "修改失败!");
				mov.setViewName("/error");
			}else{
				mov.setViewName("redirect:/siteNodeType/siteNodeTypeList.html");
			}
		}catch(Exception e){
		
			e.printStackTrace();
			mov.addObject("msg", "修改失败!");
			mov.setViewName("/error");
		}
		
		return mov;
	}
	
	
	/**
	 * 逻辑删除siteNodeType
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/delSiteNodeType")
	public ModelAndView delSiteNodeType(HttpServletRequest request, HttpServletResponse response) {
		
		ModelAndView mov = new ModelAndView(); 
		
		createParameterMap(request);
		
		try{
		
			boolean flag = siteNodeTypeService.delSiteNodeType(paramsMap);
			
			if(!flag){
				mov.addObject("msg", "删除失败!");
				mov.setViewName("/error");
			}else{
				mov.setViewName("redirect:/siteNodeType/siteNodeTypeList.html");
			}
		}catch(Exception e){
			
			e.printStackTrace();
			mov.addObject("msg", "删除失败!");
			mov.setViewName("/error");
		
		}
		
		return mov;
	}
	
	
	/**
	 * 物理删除siteNodeType
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/deleteSiteNodeType")
	public ModelAndView deleteSiteNodeType(HttpServletRequest request, HttpServletResponse response) {
		
		ModelAndView mov = new ModelAndView(); 
		
		createParameterMap(request);
		
		try{
		
			boolean flag = siteNodeTypeService.deleteSiteNodeType(paramsMap);
			
			if(!flag){
				mov.addObject("msg", "删除失败!");
				mov.setViewName("/error");
			}else{
				mov.setViewName("redirect:/siteNodeType/siteNodeTypeList.html");
			}
		}catch(Exception e){
			
			e.printStackTrace();
			mov.addObject("msg", "删除失败!");
			mov.setViewName("/error");
		
		}
		
		return mov;
	}
	
	
	
	//auto-code-end
	
	
}

